<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String basepath = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
	<head>
	<title>煤矿企业安全生产许可证综合管理系统</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="icon" href="<%=basepath %>styles/images/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="<%=basepath %>/resources/styles/base.css">
	<link rel="stylesheet" type="text/css" href="<%=basepath %>/resources/styles/default/login.css">
	<script type="text/javascript" src="<%=basepath %>/resources/plugins/jquery.js"></script>
	<script type="text/javascript" src="<%=basepath %>/resources/scripts/CoreUtil.js"></script>		
	<script type="text/javascript">var basepath="<%=basepath%>";</script>
	<script type="text/javascript" >
		$(function () {
			
			$("input[name='LOGIN_TYPE']").unbind("click").bind("click",function(){
				
				$("#userType").val($(this).val());
				
				var loginType = $(this).val() == "ZF" ? "QY" : "ZF";
				
				$(".login").removeClass(loginType);
				
				$(".login").addClass($(this).val());
				
			});
			
			var loginType = $("input[name='LOGIN_TYPE'][checked='checked']").val() == undefined ? "ZF" : $("input[name='LOGIN_TYPE'][checked='checked']").val();

			$(".login").addClass(loginType);
			
			$("input[name='LOGIN_TYPE'][value='"+loginType+"']").attr("checked",true);
			
			$("#userType").val(loginType);
			
			$(".loginBut").click(function(){
				
				$(".form input").attr("disabled","true");
				
				$("#login_msg").html("");
				
				var userAccount = $("input[name='USER_ACCOUNT']").val();
				
				var userPassword = $("input[name='USER_PASSWORD']").val();
				
				var userType = $("input[name='USER_TYPE']").val();
				
				if($.trim(userAccount) == "" ||$.trim(userPassword) == "" ){
					
					$("#login_msg").html("请输入账号和密码");
					
					$(".login input").removeAttr("disabled");
						
					return;
				}
				
				$("#login_msg").html("请稍候......正在进行登录验证");
				
				var params = {};
				
				params["USER_ACCOUNT"] = userAccount;
				
				params["USER_PASSWORD"] = userPassword;
				
				params["USER_TYPE"] = userType;
				
				$.post(basepath+"/login?data_type=json",params,function(data){
					
					if(data.success){
						
					 	window.opener=null;
			           
				     	window.open('','_self');
				        	
				     	window.close();
						
						util.openFullWin(basepath+"/index?uid="+data.uid+"&utype="+data.params.USER_TYPE);

					}else{
						
						$("#login_msg").html(data.message);
						
						$(".login input").removeAttr("disabled");
						
					}
				},"json");
				
			});
			
			$(document).keypress(function (event) {

			    if (event.which == 13) {
			    	
			    	$(".loginBut").click();
			    	
			    }
			    
			});

		});
	</script>
	
</head>

<body>
	<div class="login">
		<form action="<%=basepath %>/index" method="post" >
			<input type="hidden" id="userType" name="USER_TYPE" value="${params.USER_TYPE}"/>
			<div class="from">
				<table class="input" cellpadding="0" width="100%" cellspacing="0">
					<tr>
						<td colspan="2" align="center" style="padding-top:5px;height:30px;">
							<input type="radio" name="LOGIN_TYPE" value="ZF" ${params.LOGIN_TYPE == 'ZF' ? 'checked="checked"' : '' } style="margin-bottom:2px;"/><span>政府端</span>&ensp;&ensp;
							<input type="radio" name="LOGIN_TYPE" value="QY" ${params.LOGIN_TYPE == 'QY' ? 'checked="checked"' : '' } style="margin-bottom:2px;"/><span>企业端</span>
						</td>
					</tr>
					<tr>
						<td ><span>账&nbsp;&nbsp;&nbsp;&nbsp;号：</span></td>
						<td><input  name="USER_ACCOUNT" type="text"  value="${params.USER_ACCOUNT }" class="zinput"/></td>
					</tr>
					<tr>
						<td><span>密&nbsp;&nbsp;&nbsp;&nbsp;码：</span></td>
						<td><input  name="USER_PASSWORD" type="password" value="${params.USER_PASSWORD }" class="zinput"/></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><div class="loginBut" ></div></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><span id="login_msg">${message}</span></td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
</html>